package com.shop.controller;

import com.shop.annotation.RequiresPermissionsDesc;
import com.shop.service.DtsAddressService;
import com.shop.util.ResponseUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * @ClassName AdminRegionCrotraller
 * @Author xiao宋
 * @Date 18:55  2022/10/16
 * @Version 1.0
 * @Description TODO
 */
@Slf4j
@RestController
@RequestMapping("/admin/region")
public class AdminRegionController {
    @Autowired
    DtsAddressService addressService;
    /**
     * 商场管理  -->  显示行政取余
     * @param page
     * @param limit
     * @param name  行政区域名 --> 模糊查询
     * @param code  行政取余 ID
     * @return
     */
    @RequiresPermissions("admin:user:list")
    @RequiresPermissionsDesc(menu = {"系统管理", "地址管理"}, button = "行政列表")
    @GetMapping("/list")
    public Object footprint(
            @RequestParam(value = "page", required = false, defaultValue = "1") Integer page,
            @RequestParam(value = "limit", required = false, defaultValue = "20") Integer limit,
            String name, Integer code
    ) {

        log.debug("行政区域列表分页方法");
        Map<String, Object> data = addressService.findByAdministrativeDivisionPage(page, limit,name,code);
        log.debug("行政区域分页方法显示完毕");
        return ResponseUtil.ok(data);
    }
}
